package com.lhl;

import com.lhl.abstracts.factory.Factory1;
import com.lhl.abstracts.factory.Factory2;
import com.lhl.abstracts.product.base.ProductA;
import com.lhl.abstracts.product.base.ProductB;
import com.lhl.method.factory.FactoryProductA;
import com.lhl.method.factory.FactoryProductB;
import com.lhl.method.factory.abstracts.AbstractFactory;
import com.lhl.simple.SimpleFactory;
import com.lhl.simple.product.ProductEnum;
import com.lhl.simple.product.base.Product;


/**
 * @author 刘翰林
 * @create 2024-09-12 23:52
 */
public class Main {
    public static void main(String[] args) {
        // 1、简单工厂调用
//        simpleFactoryRun();

        // 2、工厂方法调用
//        methodFactoryRun();

        // 3、抽象工厂方法调用
        abstractFactoryRun();

    }


    /**
     * 简单工厂使用示例
     */
    public static void simpleFactoryRun(){
        Product productA = SimpleFactory.createProduct(ProductEnum.ProductA);
        Product productB = SimpleFactory.createProduct(ProductEnum.ProductB);
        System.out.println(productA.show());
        System.out.println(productB.show());
    }

    /**
     * 工厂方法使用示例
     */
    public static void methodFactoryRun(){
        AbstractFactory factoryA = new FactoryProductA();
        AbstractFactory factoryB = new FactoryProductB();

        com.lhl.method.product.base.Product productA = factoryA.createProduct();
        com.lhl.method.product.base.Product productB = factoryB.createProduct();

        System.out.println(productA.show());
        System.out.println(productB.show());
    }

    /**
     * 抽象工厂使用示例
     */
    public static void abstractFactoryRun(){

        com.lhl.abstracts.factory.AbstractFactory factory1 = new Factory1();
        ProductA productA1 = factory1.createProductA();
        ProductB productB1 = factory1.createProductB();

        com.lhl.abstracts.factory.AbstractFactory factory2 = new Factory2();
        ProductA productA2 = factory2.createProductA();
        ProductB productB2 = factory2.createProductB();

        System.out.println(productA1.show());
        System.out.println(productA2.show());
        System.out.println(productB1.show());
        System.out.println(productB2.show());
    }

}
